ncreader: bring cursor back following putegc #839

This commit is contained in:
nick black 2020-08-25 18:17:20 -04:00
parent 66b523413b
commit 9b1ae7d970
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 16 additions and 1 deletions

View File

@ -181,6 +181,12 @@ int ncreader_write_egc(ncreader* n, const char* egc){
logerror(n->ncp->nc, "Fed illegal UTF-8 [%s]\n", egc);
return -1;
}
int viewx = n->ncp->x;
int textx = n->textarea->x;
int y = n->ncp->y;
fprintf(stderr, "putting [%s]: tcurs: %dx%d vcurs: %dx%d xproj: %d\n", egc, y, textx, y, viewx, n->xproject);
if(n->textarea->x >= n->textarea->lenx - cols){
if(n->horscroll){
if(ncplane_resize_simple(n->textarea, n->textarea->leny, n->textarea->lenx + cols)){
@ -198,6 +204,15 @@ int ncreader_write_egc(ncreader* n, const char* egc){
if(ncplane_putegc(n->ncp, egc, NULL) < 0){
return -1;
}
if(n->ncp->x >= n->ncp->lenx){
n->ncp->x = n->ncp->lenx - 1;
}
viewx = n->ncp->x;
textx = n->textarea->x;
y = n->ncp->y;
fprintf(stderr, "put [%s]: tcurs: %dx%d vcurs: %dx%d xproj: %d\n", egc, y, textx, y, viewx, n->xproject);
return 0;
}

View File

@ -35,7 +35,7 @@ auto main(int argc, const char** argv) -> int {
nc.get_term_dim(&dimy, &dimx);
ncreader_options opts{};
opts.physrows = 2;//dimy / 8;
opts.physcols = dimx / 2;
opts.physcols = 20; //dimx / 2;
opts.egc = "";
opts.flags = horscroll ? NCREADER_OPTION_HORSCROLL : 0;
// FIXME c++ is crashing