|
|
@ -1510,6 +1510,7 @@ int ncplane_puttext(ncplane* n, int y, ncalign_e align, const char* text, size_t
|
|
|
|
// might catch a space, in which case we want breaker updated. if it's
|
|
|
|
// 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.
|
|
|
|
// 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?
|
|
|
|
|
|
|
|
//fprintf(stderr, "laying out [%s] at %d (%d)\n", linestart, x, dimx);
|
|
|
|
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);
|
|
|
@ -1538,27 +1539,28 @@ int ncplane_puttext(ncplane* n, int y, ncalign_e align, const char* text, size_t
|
|
|
|
x += width;
|
|
|
|
x += width;
|
|
|
|
text += consumed;
|
|
|
|
text += consumed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int carrycols = 0;
|
|
|
|
//fprintf(stderr, "exited at %d (%d) looking at %.*s\n", x, dimx, breaker - linestart, linestart);
|
|
|
|
if(x > dimx){
|
|
|
|
// if we have no breaker, we got a word that was longer than our line;
|
|
|
|
// the last character was one past the amount we can print.
|
|
|
|
// print what we can and move along. if *text is nul, we're done.
|
|
|
|
// set carrycols to the amount since breaker.
|
|
|
|
|
|
|
|
carrycols = text - breaker;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
totalcols += (breaker - linestart);
|
|
|
|
|
|
|
|
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
|
|
|
|
int carrycols = 0;
|
|
|
|
if(ncplane_putnstr_yx(n, y, xpos, breaker - linestart, linestart) < 0){
|
|
|
|
carrycols = text - breaker;
|
|
|
|
if(bytes){
|
|
|
|
if(breaker != linestart){
|
|
|
|
*bytes = linestart - beginning;
|
|
|
|
totalcols += (breaker - linestart);
|
|
|
|
|
|
|
|
const int xpos = ncplane_align(n, align, x);
|
|
|
|
|
|
|
|
// blows out if we supply a y beyond leny
|
|
|
|
|
|
|
|
if(ncplane_putnstr_yx(n, y, xpos, breaker - linestart, linestart) < 0){
|
|
|
|
|
|
|
|
if(bytes){
|
|
|
|
|
|
|
|
*bytes = linestart - beginning;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x = carrycols;
|
|
|
|
x = carrycols;
|
|
|
|
linestart = breaker + 1;
|
|
|
|
linestart = breaker + 1;
|
|
|
|
++y; // FIXME scrolling!
|
|
|
|
++y; // FIXME scrolling!??!!
|
|
|
|
}while(*text);
|
|
|
|
}while(*text);
|
|
|
|
if(bytes){
|
|
|
|
if(bytes){
|
|
|
|
*bytes = text - beginning;
|
|
|
|
*bytes = text - beginning;
|
|
|
|