2 /***************************************************************************
4 ****************************************************************************
5 * ncurses is copyright (C) 1992-1995 *
7 * zmbenhal@netcom.com *
9 * esr@snark.thyrsus.com *
11 * Permission is hereby granted to reproduce and distribute ncurses *
12 * by any means and for any fee, whether alone or as part of a *
13 * larger distribution, in source or in binary form, PROVIDED *
14 * this notice is included with any such distribution, and is not *
15 * removed from any of its header files. Mention of ncurses in any *
16 * applications linked with it is highly appreciated. *
18 * ncurses comes AS IS with no warranty, implied or expressed. *
20 ***************************************************************************/
27 ** The routine winsnstr().
31 #include <curses.priv.h>
34 MODULE_ID("$Id: lib_insstr.c,v 1.9 1997/02/15 16:09:53 tom Exp $")
36 int winsnstr(WINDOW *win, const char *str, int n)
38 short oy = win->_cury;
39 short ox = win->_curx;
42 T((T_CALLED("winsstr(%p,%s,%d)"), win, _nc_visbuf(str), n));
44 for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
45 if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b')
46 _nc_waddch_nosync(win, (chtype)(*cp));
47 else if (is7bits(*cp) && iscntrl(*cp)) {
48 winsch(win, ' ' + (chtype)(*cp));
52 winsch(win, (chtype)(*cp));
55 if (win->_curx > win->_maxx)
56 win->_curx = win->_maxx;