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)"), (void *) win, _nc_viswbufn(wstr, n), n)); if (win != 0 && wstr != 0) { if (n < 1) n = (int) wcslen(wstr); code = OK; if (n > 0) { SCREEN *sp = _nc_screen_of(win); oy = win->_cury; ox = win->_curx; for (cp = wstr; *cp && ((cp - wstr) < n); cp++) { int len = wcwidth(*cp); if ((len >= 0 && len != 1) || !is7bits(*cp)) { cchar_t tmp_cchar; wchar_t tmp_wchar = *cp; memset(&tmp_cchar, 0, sizeof(tmp_cchar)); (void) setcchar(&tmp_cchar, &tmp_wchar, WA_NORMAL, (short) 0, (void *) 0); code = _nc_insert_wch(win, &tmp_cchar); } else { /* tabs, other ASCII stuff */ code = _nc_insert_ch(sp, win, (chtype) (*cp)); } if (code != OK) break; } win->_curx = ox; win->_cury = oy; _nc_synchook(win); } } returnCode(code); }
winsnstr(WINDOW *win, const char *s, int n) { int code = ERR; NCURSES_SIZE_T oy; NCURSES_SIZE_T ox; const unsigned char *str = (const unsigned char *) s; const unsigned char *cp; T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbufn(s, n), n)); if (win != 0 && str != 0) { oy = win->_cury; ox = win->_curx; for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) { _nc_insert_ch(win, (chtype) UChar(*cp)); } win->_curx = ox; win->_cury = oy; _nc_synchook(win); code = OK; } returnCode(code); }