Support newlines in ncplane_putnstr() when scrolling #793

pull/803/head
nick black 4 years ago
parent 94a815b7d8
commit 86a75531c6
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -4,6 +4,7 @@
#include <wchar.h>
#include <errno.h>
#include <stdio.h>
#include <wctype.h>
#include <stddef.h>
#include <assert.h>
#include <stdlib.h>
@ -83,6 +84,10 @@ utf8_egc_len(const char* gcluster, int* colcount){
if(*colcount){ // this must be starting a new EGC, exit and do not claim
break;
}
if(cols < 0 && iswspace(wc)){ // newline or tab
cols = 0;
return ret + 1;
}
*colcount += cols;
}
ret += r;

@ -2309,9 +2309,9 @@ int ncplane_putnstr_aligned(struct ncplane* n, int y, ncalign_e align, size_t s,
}
int ncplane_putnstr_yx(struct ncplane* n, int y, int x, size_t s, const char* gclusters){
size_t ret = 0;
int ret = 0;
// FIXME speed up this blissfully naive solution
while(ret < s && *gclusters){
while((size_t)ret < s && *gclusters){
int wcs;
int cols = ncplane_putegc_yx(n, y, x, gclusters, &wcs);
if(cols < 0){

@ -42,7 +42,8 @@ int main(int argc, char** argv){
}
setlocale(LC_ALL, "");
notcurses_options opts = {
.flags = NCOPTION_INHIBIT_SETLOCALE | NCOPTION_NO_ALTERNATE_SCREEN,
.flags = NCOPTION_INHIBIT_SETLOCALE | NCOPTION_NO_ALTERNATE_SCREEN |
NCOPTION_SUPPRESS_BANNERS,
};
struct notcurses* nc = notcurses_init(&opts, NULL);
struct ncplane* n = notcurses_stdplane(nc);

@ -43,7 +43,8 @@ int main(int argc, char** argv){
}
setlocale(LC_ALL, "");
notcurses_options opts = {
.flags = NCOPTION_INHIBIT_SETLOCALE | NCOPTION_NO_ALTERNATE_SCREEN,
.flags = NCOPTION_INHIBIT_SETLOCALE | NCOPTION_NO_ALTERNATE_SCREEN |
NCOPTION_SUPPRESS_BANNERS,
};
struct notcurses* nc = notcurses_init(&opts, NULL);
if(nc == NULL){

Loading…
Cancel
Save