mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-06 03:20:26 +00:00
ncplane_resize: rebuild TAM #1750
This commit is contained in:
parent
ad13e5c428
commit
d7d032732f
@ -666,6 +666,7 @@ int ncplane_resize_internal(ncplane* n, int keepy, int keepx, int keepleny,
|
||||
// we're good to resize. we'll need alloc up a new framebuffer, and copy in
|
||||
// those elements we're retaining, zeroing out the rest. alternatively, if
|
||||
// we've shrunk, we will be filling the new structure.
|
||||
int oldarea = rows * cols;
|
||||
int keptarea = keepleny * keeplenx;
|
||||
int newarea = ylen * xlen;
|
||||
size_t fbsize = sizeof(nccell) * newarea;
|
||||
@ -673,6 +674,20 @@ int ncplane_resize_internal(ncplane* n, int keepy, int keepx, int keepleny,
|
||||
if(fb == NULL){
|
||||
return -1;
|
||||
}
|
||||
if(n->tam){
|
||||
loginfo(ncplane_notcurses_const(n), "TAM realloc to %d entries\n", newarea);
|
||||
tament* tmptam = realloc(n->tam, sizeof(*tmptam) * newarea);
|
||||
if(tmptam == NULL){
|
||||
free(fb);
|
||||
return -1;
|
||||
}
|
||||
n->tam = tmptam;
|
||||
// FIXME need to set up the entries based on new distribution for
|
||||
// cell-pixel geometry change, and split across new rows
|
||||
if(newarea > oldarea){
|
||||
memset(n->tam + oldarea, 0, sizeof(*n->tam) * (newarea - oldarea));
|
||||
}
|
||||
}
|
||||
// update the cursor, if it would otherwise be off-plane
|
||||
if(n->y >= ylen){
|
||||
n->y = ylen - 1;
|
||||
|
Loading…
Reference in New Issue
Block a user