resize method
void
resize(])
override
Resize the terminal screen. newWidth and newHeight should be greater
than 0. Main-buffer text is reflowed when reflowEnabled is true.
Implementation
@override
void resize(
int newWidth,
int newHeight, [
int? pixelWidth,
int? pixelHeight,
]) {
if (_isDisposed) return;
newWidth = max(newWidth, 1);
newHeight = max(newHeight, 1);
final nextCellPixelWidth = pixelWidth ?? _cellPixelWidth;
final nextCellPixelHeight = pixelHeight ?? _cellPixelHeight;
if (newWidth == _viewWidth &&
newHeight == _viewHeight &&
nextCellPixelWidth == _cellPixelWidth &&
nextCellPixelHeight == _cellPixelHeight) {
return;
}
final wasSynchronizedUpdateMode = _synchronizedUpdateMode;
if (wasSynchronizedUpdateMode) {
_synchronizedUpdateTimer?.cancel();
_synchronizedUpdateTimer = null;
_synchronizedUpdateMode = false;
}
onResize?.call(newWidth, newHeight, pixelWidth ?? 0, pixelHeight ?? 0);
if (pixelWidth != null) {
_cellPixelWidth = pixelWidth;
}
if (pixelHeight != null) {
_cellPixelHeight = pixelHeight;
}
//we need to resize both buffers so that they are ready when we switch between them
_altBuffer.resize(_viewWidth, _viewHeight, newWidth, newHeight);
_mainBuffer.resize(_viewWidth, _viewHeight, newWidth, newHeight);
_viewWidth = newWidth;
_viewHeight = newHeight;
if (buffer == _altBuffer) {
buffer.clearScrollback();
}
_altBuffer.resetVerticalMargins();
_mainBuffer.resetVerticalMargins();
if (wasSynchronizedUpdateMode) notifyListeners();
if (_inBandSizeReportMode) _sendInBandSizeReport();
}