diff --git a/src/components/screen.c b/src/components/screen.c index b6512d3..126f2d0 100644 --- a/src/components/screen.c +++ b/src/components/screen.c @@ -74,6 +74,20 @@ nn_bool_t nn_unsafeReallocateScreenBuffer(nn_screen *screen, int maxWidth, int m return false; } + for(nn_size_t y = 0; y < maxHeight; y++) { + if(y == screen->maxHeight) break; + for(nn_size_t x = 0; x < maxWidth; x++) { + if(x == screen->maxWidth) break; + + nn_size_t srcIdx = x + y * screen->maxWidth; + nn_size_t destIdx = x + y * maxWidth; + + newBuffer[destIdx] = screen->buffer[srcIdx]; + } + } + + nn_dealloc(alloc, screen->buffer, sizeof(nn_scrchr_t) * screen->maxWidth * screen->maxHeight); + screen->buffer = newBuffer; screen->maxWidth = maxWidth; screen->maxHeight = maxHeight;