|
|
@ -1506,10 +1506,11 @@ int ncplane_puttext(ncplane* n, int y, ncalign_e align, const char* text, size_t
|
|
|
|
// figure how much text to output on this line
|
|
|
|
// figure how much text to output on this line
|
|
|
|
mbstate_t mbstate = {};
|
|
|
|
mbstate_t mbstate = {};
|
|
|
|
int width;
|
|
|
|
int width;
|
|
|
|
// verified columns thus far (carried, and through breaker)
|
|
|
|
// let it go all the way through to dimx. on that last hit of dimx, we
|
|
|
|
size_t verifiedcols = x;
|
|
|
|
// might catch a space, in which case we want breaker updated. if it's
|
|
|
|
|
|
|
|
// not a space, it won't be printed, and we carry the word forward.
|
|
|
|
// FIXME what ought be done with \n or multiple spaces?
|
|
|
|
// FIXME what ought be done with \n or multiple spaces?
|
|
|
|
while(*text && x < dimx){
|
|
|
|
while(*text && x <= dimx){
|
|
|
|
wchar_t w;
|
|
|
|
wchar_t w;
|
|
|
|
size_t consumed = mbrtowc(&w, text, MB_CUR_MAX, &mbstate);
|
|
|
|
size_t consumed = mbrtowc(&w, text, MB_CUR_MAX, &mbstate);
|
|
|
|
if(consumed == (size_t)-2 || consumed == (size_t)-1){
|
|
|
|
if(consumed == (size_t)-2 || consumed == (size_t)-1){
|
|
|
@ -1530,7 +1531,6 @@ int ncplane_puttext(ncplane* n, int y, ncalign_e align, const char* text, size_t
|
|
|
|
// FIXME use the more advanced unicode functionality to break lines
|
|
|
|
// FIXME use the more advanced unicode functionality to break lines
|
|
|
|
if(iswspace(w)){
|
|
|
|
if(iswspace(w)){
|
|
|
|
breaker = text;
|
|
|
|
breaker = text;
|
|
|
|
verifiedcols = x;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(x + width > dimx){
|
|
|
|
if(x + width > dimx){
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -1539,16 +1539,17 @@ int ncplane_puttext(ncplane* n, int y, ncalign_e align, const char* text, size_t
|
|
|
|
text += consumed;
|
|
|
|
text += consumed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int carrycols = 0;
|
|
|
|
int carrycols = 0;
|
|
|
|
if(x >= dimx){
|
|
|
|
if(x > dimx){
|
|
|
|
// the last character was one past the amount we can print. set linestart
|
|
|
|
// the last character was one past the amount we can print.
|
|
|
|
// back to breaker, set carrycols to the amount since breaker
|
|
|
|
// set carrycols to the amount since breaker.
|
|
|
|
carrycols = x - verifiedcols;
|
|
|
|
carrycols = text - breaker;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
totalcols += verifiedcols;
|
|
|
|
totalcols += (breaker - linestart);
|
|
|
|
const int xpos = ncplane_align(n, align, x);
|
|
|
|
const int xpos = ncplane_align(n, align, x);
|
|
|
|
if(!*text || breaker == NULL){
|
|
|
|
if(!*text || breaker == NULL){
|
|
|
|
breaker = text;
|
|
|
|
breaker = text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// blows out if we supply a y beyond leny
|
|
|
|
if(ncplane_putnstr_yx(n, y, xpos, breaker - linestart, linestart) < 0){
|
|
|
|
if(ncplane_putnstr_yx(n, y, xpos, breaker - linestart, linestart) < 0){
|
|
|
|
if(bytes){
|
|
|
|
if(bytes){
|
|
|
|
*bytes = linestart - beginning;
|
|
|
|
*bytes = linestart - beginning;
|
|
|
|