src/liflines/cscurses.c
/*============================
 * mvcwaddnstr -- convert to GUI codeset & call mvwaddstr with length limit
 * Created: 2002/12/13 (Perry Rapp)
  *==========================*/
- convert to GUI codeset & call mvwaddstr with length limit
Created: 2002/12/13 (Perry Rapp)
- convert to GUI codeset & call mvwaddstr with length limit Created : 2002 / 12 / 13 ( Perry Rapp )
int
mvccwaddnstr (WINDOW *wp, int y, int x, const char *cp, int n)
{
	ZSTR zstr = zs_news(cp);
	int rtn=0;
	int_to_disp(zstr);
	if (zs_len(zstr) < (unsigned int)n) {
		rtn = mvwaddstr(wp, y, x, zs_str(zstr));
	} else {
		if (output_width(zstr) > (size_t)n) {
			STRING str = zs_str(zstr);
			INT width=0;
			STRING prev = find_prev_char(&str[n-1], &width, str, gui8);
			width += (prev - str);
			zs_chop(zstr, width);
		}
		rtn = mvwaddnstr(wp, y, x, zs_str(zstr), n);
	}
	zs_free(&zstr);
	return rtn;
}
int mvccwaddnstr ( WINDOW * wp , int y , int x , const char * cp , int n ) { ZSTR zstr = zs_news ( cp ) ; int rtn = 0 ; int_to_disp ( zstr ) ; if ( zs_len ( zstr ) < ( unsigned int ) n ) { rtn = mvwaddstr ( wp , y , x , zs_str ( zstr ) ) ; } else { if ( output_width ( zstr ) > ( size_t ) n ) { STRING str = zs_str ( zstr ) ; INT width = 0 ; STRING prev = find_prev_char ( & str [ n - 1 ] , & width , str , gui8 ) ; width += ( prev - str ) ; zs_chop ( zstr , width ) ; } rtn = mvwaddnstr ( wp , y , x , zs_str ( zstr ) , n ) ; } zs_free ( & zstr ) ; return rtn ; }
mvcwaddnstr -- convert to GUI codeset & call mvwaddstr with length limit
 Created: 2002/12/13 (Perry Rapp)
mvcwaddnstr -- convert to GUI codeset & call mvwaddstr with length limit Created : 2002 / 12 / 13 ( Perry Rapp )
/* We need to do length truncation correctly for UTF-8 output */ /* #1) We need to not break UTF-8 multibytes */ /* #2) We should account for zero-width characters, eg, use wcwidth */ /* Unfortunately, lifelines doesn't yet use wcwidth or config test it */ /* TODO:
			config test for wcswidth
			and substitute Markus Kuhn's
			http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
			*/