/* * mvwinsnstr -- * Do an insert-n-string on the line at (y, x) in the given window. */ int mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n) { if (wmove(win, y, x) == ERR) return ERR; return winsnstr(stdscr, str, n); }
WRAP_API int wrap_winsnstr(WINDOW *win, uchar2 *str, int n) { #if defined(CURSES_WIDE) && SIZEOF_WCHAR_T == 2 return wins_nwstr(win, str, n); #elif defined(CURSES_WIDE) wchar_t stackbuf[BUFFER_SIZE]; xbuffer xinput, xoutput; int ret; xbuf_init_uc(&xinput, str, n, XBUF_FILL); xbuf_init_wc(&xoutput, stackbuf, BUFFER_SIZE, XBUF_EXPANDABLE); ret = unicode_to_wchar(&xinput, &xoutput); if (ret < 0) goto do_exit; ret = xbuf_tzero_wc(&xoutput); if (ret < 0) goto do_exit; ret = wins_nwstr(win, xbuf_data_wc(&xoutput), xbuf_len_wc(&xoutput)); do_exit: xbuf_free(&xoutput); return ret; #else char stackbuf[BUFFER_SIZE]; xbuffer xinput, xoutput; int ret; xbuf_init_uc(&xinput, str, n, XBUF_FILL); xbuf_init(&xoutput, stackbuf, BUFFER_SIZE, XBUF_EXPANDABLE); ret = unicode_to_char(&xinput, &xoutput); if (ret < 0) goto do_exit; ret = xbuf_tzero(&xoutput); if (ret < 0) goto do_exit; ret = winsnstr(win, xbuf_data(&xoutput), xbuf_len(&xoutput)); do_exit: xbuf_free(&xoutput); return ret; #endif }
EIF_INTEGER c_ecurses_winsnstr (EIF_POINTER w, EIF_POINTER s, EIF_INTEGER n) { return winsnstr( ((WINDOW *) w) , (char *)s, (int) n) ; };
/* * insnstr -- * insert a multi-byte character string into the current window * with at most n characters */ int insnstr(const char *str, int n) { return winsnstr(stdscr, str, n); }
/* * winsstr -- * Do an insert-string on the line, leaving (cury, curx) unchanged. * No wrapping. */ int winsstr(WINDOW *win, const char *str) { return winsnstr( win, str, -1 ); }
NCURSES_EXPORT(int) (winsstr) (WINDOW * a1, const char * z) { T((T_CALLED("winsstr(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(winsnstr(a1, z, -1)); }
NCURSES_EXPORT(int) (mvwinsstr) (WINDOW * a1, int a2, int a3, const char * z) { T((T_CALLED("mvwinsstr(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _nc_visbuf2(3,z))); returnCode((wmove(a1,a2,a3) == (-1) ? (-1) : winsnstr(a1, z, -1))); }
NCURSES_EXPORT(int) (mvinsstr) (int a1, int a2, const char * z) { T((T_CALLED("mvinsstr(%d,%d,%s)"), a1, a2, _nc_visbuf2(2,z))); returnCode((wmove(stdscr,a1,a2) == (-1) ? (-1) : winsnstr(stdscr, z, -1))); }
NCURSES_EXPORT(int) (insstr) (const char * z) { T((T_CALLED("insstr(%s)"), _nc_visbuf2(0,z))); returnCode(winsnstr(stdscr, z, -1)); }
NCURSES_EXPORT(int) (insnstr) (const char * a1, int z) { T((T_CALLED("insnstr(%s,%d)"), _nc_visbuf2(0,a1), z)); returnCode(winsnstr(stdscr,a1,z)); }