mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-10-31 15:20:13 +00:00
ncplane_puttext(): allow NULL for sbytes
This commit is contained in:
parent
472b6a3f54
commit
3f114f4305
3
NEWS.md
3
NEWS.md
@ -1,6 +1,9 @@
|
||||
This document attempts to list user-visible changes and any major internal
|
||||
rearrangements of Notcurses.
|
||||
|
||||
* 1.5.2 (not yet released)
|
||||
* A `NULL` value can now be passed as `sbytes` to `ncplane_puttext()`.
|
||||
|
||||
* 1.5.1 (2020-07-15)
|
||||
* The semantics of rendering have changed slightly. In 1.5.0 and prior
|
||||
versions, a cell without a glyph was replaced *in toto* by that plane's
|
||||
|
@ -1507,13 +1507,17 @@ int ncplane_puttext(ncplane* n, int y, ncalign_e align, const char* text, size_t
|
||||
size_t consumed = mbrtowc(&w, text, MB_CUR_MAX, &mbstate);
|
||||
if(consumed == (size_t)-2 || consumed == (size_t)-1){
|
||||
logerror(n->nc, "Invalid UTF-8 after %zu bytes\n", text - beginning);
|
||||
*bytes = text - beginning;
|
||||
if(bytes){
|
||||
*bytes = text - beginning;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
width = wcwidth(w);
|
||||
if(width < 0){
|
||||
logerror(n->nc, "Non-printable UTF-8 after %zu bytes\n", text - beginning);
|
||||
*bytes = text - beginning;
|
||||
if(bytes){
|
||||
*bytes = text - beginning;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if(x + width >= dimx){
|
||||
@ -1539,14 +1543,18 @@ int ncplane_puttext(ncplane* n, int y, ncalign_e align, const char* text, size_t
|
||||
breaker = text;
|
||||
}
|
||||
if(ncplane_putnstr_yx(n, y, xpos, breaker - linestart, linestart) < 0){
|
||||
*bytes = linestart - beginning;
|
||||
if(bytes){
|
||||
*bytes = linestart - beginning;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
x = carrycols;
|
||||
linestart = breaker + 1;
|
||||
++y; // FIXME scrolling!
|
||||
}while(*text);
|
||||
*bytes = text - beginning;
|
||||
if(bytes){
|
||||
*bytes = text - beginning;
|
||||
}
|
||||
return totalcols;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user