resize method

  1. @override
void resize(
  1. int newWidth,
  2. int newHeight, [
  3. int? pixelWidth,
  4. int? pixelHeight,
])
override

Resize the terminal screen. newWidth and newHeight should be greater than 0. Text reflow is currently not implemented and will be avaliable in the future.

Implementation

@override
void resize(
  int newWidth,
  int newHeight, [
  int? pixelWidth,
  int? pixelHeight,
]) {
  newWidth = max(newWidth, 1);
  newHeight = max(newHeight, 1);

  onResize?.call(newWidth, newHeight, pixelWidth ?? 0, pixelHeight ?? 0);

  //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();
}