Try to fix garbage appearing when resizing window. Redraw is probably done a little bit too often.

This commit is contained in:
DarwinNE 2020-02-25 22:03:37 +01:00
parent cf75b4d9ba
commit 1f19d619cf

View File

@ -520,9 +520,10 @@ void Console::Reshape(Rect newBounds)
if(!consolePort) if(!consolePort)
return; return;
InsetRect(&newBounds, 2,2);
bounds = newBounds; bounds = newBounds;
InsetRect(&bounds, 2,2);
short newRows = (bounds.bottom - bounds.top) / cellSizeY; short newRows = (bounds.bottom - bounds.top) / cellSizeY;
short newCols = (bounds.right - bounds.left) / cellSizeX; short newCols = (bounds.right - bounds.left) / cellSizeX;
@ -532,7 +533,7 @@ void Console::Reshape(Rect newBounds)
upshift = cursorY - (newRows - 1); upshift = cursorY - (newRows - 1);
InvalidateCursor(); InvalidateCursor();
cursorY = newRows - 1; cursorY = std::max(newRows - 1, 0) ;
} }
std::vector<AttributedChar> newChars(newRows*newCols, AttributedChar(' ', currentAttr)); std::vector<AttributedChar> newChars(newRows*newCols, AttributedChar(' ', currentAttr));
@ -543,25 +544,17 @@ void Console::Reshape(Rect newBounds)
std::copy(src, src + std::min(cols, newCols), dst); std::copy(src, src + std::min(cols, newCols), dst);
} }
chars.swap(newChars); chars.swap(newChars);
/*newChars = std::vector<char>(newRows*newCols, ' ');
for(short row = 0; row < newRows && row < rows; row++)
{
char *src = &chars[row * cols];
char *dst = &newChars[row * newCols];
std::copy(src, src + std::min(cols, newCols), dst);
}
onscreen.swap(newChars);*/
onscreen = newChars; onscreen = newChars;
rows = newRows; rows = newRows;
cols = newCols; cols = newCols;
if(upshift)
{ dirtyRect = Rect { 0, 0, rows, cols };
//dirtyRect = Rect { 0, 0, rows, cols }; EraseRect(&newBounds);
//Update(); Update();
Draw(); Draw(newBounds);
}
} }
char Console::WaitNextChar() char Console::WaitNextChar()