src/ui-term.c
errr Term_addstr(int n, int a, const char *buf)
{
	int k;

	int w = Term->wid;

	errr res = 0;

	wchar_t s[1024];

	/* Copy to a rewriteable string */
 	text_mbstowcs(s, buf, 1024);

	/* Handle "unusable" cursor */
	if (Term->scr->cu) return (-1);

	/* Obtain maximal length */
	k = (n < 0) ? (w + 1) : n;

	/* Obtain the usable string length */
	for (n = 0; (n < k) && s[n]; n++) /* loop */;

	/* React to reaching the edge of the screen */
	if (Term->scr->cx + n >= w) res = n = w - Term->scr->cx;

	/* Queue the first "n" characters for display */
	Term_queue_chars(Term->scr->cx, Term->scr->cy, n, a, s);

	/* Advance the cursor */
	Term->scr->cx += n;

	/* Hack -- Notice "Useless" cursor */
	if (res) Term->scr->cu = 1;

	/* Success (usually) */
	return (res);
}
/**
 * At the current location, using an attr, add a string
 *
 * We also take a length "n", using negative values to imply
 * the largest possible value, and then we use the minimum of
 * this length and the "actual" length of the string as the
 * actual number of characters to attempt to display, never
 * displaying more characters than will actually fit, since
 * we do NOT attempt to "wrap" the cursor at the screen edge.
 *
 * We return "-1" if the cursor is currently unusable.
 * We return "N" if we were "only" able to write "N" chars,
 * even if all of the given characters fit on the screen,
 * and mark the cursor as unusable for future attempts.
 *
 * So when this function, or the preceding one, return a
 * positive value, future calls to either function will
 * return negative ones.
 */


We return "-1" if the cursor is currently unusable.

So when this function, or the preceding one, return a
positive value, future calls to either function will
return negative ones.
We return " - 1 " if the cursor is currently unusable . So when this function or the preceding one return a positive value future calls to either function will return negative ones .
errr Term_addstr(int n, int a, const char *buf)
{
	int k;
	int w = Term->wid;
	errr res = 0;
	wchar_t s[1024];
 	text_mbstowcs(s, buf, 1024);
	if (Term->scr->cu) return (-1);
	k = (n < 0) ? (w + 1) : n;
	for (n = 0; (n < k) && s[n]; n++) ;
	if (Term->scr->cx + n >= w) res = n = w - Term->scr->cx;
	Term_queue_chars(Term->scr->cx, Term->scr->cy, n, a, s);
	Term->scr->cx += n;
	if (res) Term->scr->cu = 1;
	return (res);
}
errr Term_addstr ( int n , int a , const char * buf ) { int k ; int w = Term -> wid ; errr res = 0 ; wchar_t s [ 1024 ] ; text_mbstowcs ( s , buf , 1024 ) ; if ( Term -> scr -> cu ) return ( -1 ) ; k = ( n < 0 ) ? ( w + 1 ) : n ; for ( n = 0 ; ( n < k ) && s [ n ] ; n ++ ) ; if ( Term -> scr -> cx + n >= w ) res = n = w - Term -> scr -> cx ; Term_queue_chars ( Term -> scr -> cx , Term -> scr -> cy , n , a , s ) ; Term -> scr -> cx += n ; if ( res ) Term -> scr -> cu = 1 ; return ( res ) ; }
At the current location, using an attr, add a string
 We also take a length "n", using negative values to imply
 the largest possible value, and then we use the minimum of
 this length and the "actual" length of the string as the
 actual number of characters to attempt to display, never
 displaying more characters than will actually fit, since
 we do NOT attempt to "wrap" the cursor at the screen edge.
At the current location using an attr add a string We also take a length " n " using negative values to imply the largest possible value and then we use the minimum of this length and the " actual " length of the string as the actual number of characters to attempt to display never displaying more characters than will actually fit since we do NOT attempt to " wrap " the cursor at the screen edge .
/* Copy to a rewriteable string */ /* Handle "unusable" cursor */ /* Obtain maximal length */ /* Obtain the usable string length */ /* loop */ /* React to reaching the edge of the screen */ /* Queue the first "n" characters for display */ /* Advance the cursor */ /* Hack -- Notice "Useless" cursor */ /* Success (usually) */