Exemplo n.º 1
0
waddnstr(WINDOW *win, const char *astr, int n)
{
    const char *str = astr;
    int code = ERR;

    T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbufn(astr, n), n));

    if (win && (str != 0)) {
	TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs)));
	code = OK;
	if (n < 0)
	    n = (int) strlen(astr);

	TR(TRACE_VIRTPUT, ("str is not null, length = %d", n));
	while ((n-- > 0) && (*str != '\0')) {
	    NCURSES_CH_T ch;
	    TR(TRACE_VIRTPUT, ("*str = %#o", UChar(*str)));
	    SetChar(ch, UChar(*str++), A_NORMAL);
	    if (_nc_waddch_nosync(win, ch) == ERR) {
		code = ERR;
		break;
	    }
	}
	_nc_synchook(win);
    }
    TR(TRACE_VIRTPUT, ("waddnstr returns %d", code));
    returnCode(code);
}
Exemplo n.º 2
0
int
waddnstr(WINDOW *win, const char *const astr, int n)
{
    unsigned const char *str = (unsigned const char *)astr;
    int code = ERR;

    T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n));

    if (win && (str != 0)) {
        T(("... current %s", _traceattr(win->_attrs)));
        TR(TRACE_VIRTPUT, ("str is not null"));
        code = OK;
        if (n < 0)
            n = (int)strlen(astr);

        while((n-- > 0) && (*str != '\0')) {
            TR(TRACE_VIRTPUT, ("*str = %#x", *str));
            if (_nc_waddch_nosync(win, (chtype)*str++) == ERR) {
                code = ERR;
                break;
            }
        }
        _nc_synchook(win);
    }
    TR(TRACE_VIRTPUT, ("waddnstr returns %d", code));
    returnCode(code);
}
Exemplo n.º 3
0
wins_nwstr(WINDOW *win, const wchar_t * wstr, int n)
{
    int code = ERR;
    NCURSES_SIZE_T oy;
    NCURSES_SIZE_T ox;
    const wchar_t *cp;

    T((T_CALLED("wins_nwstr(%p,%s,%d)"), win, _nc_viswbufn(wstr,n), n));

    if (win != 0
	&& wstr != 0
	&& wcwidth(*wstr) > 0) {
	code = OK;
	if (n < 1)
	    n = wcslen(wstr);
	oy = win->_cury;
	ox = win->_curx;
	for (cp = wstr; *cp && ((cp - wstr) < n); cp++) {
	    NCURSES_CH_T wch;
	    SetChar2(wch, *cp);
	    if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b') {
		_nc_waddch_nosync(win, wch);
	    } else if (is7bits(*cp) && iscntrl(*cp)) {
		winsch(win, ' ' + (chtype) (*cp));
		winsch(win, (chtype) '^');
		win->_curx += 2;
	    } else if (wins_wch(win, &wch) == ERR
		       || win->_curx > win->_maxx) {
		break;
	    }
	}

	win->_curx = ox;
	win->_cury = oy;
	_nc_synchook(win);
	code = OK;
    }
    returnCode(code);
}