resize method

  1. @override
void resize(
  1. int newWidth,
  2. int newHeight,
  3. int newPixelWidth,
  4. int newPixelHeight,
)
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 newPixelWidth, int newPixelHeight) {
  backend?.resize(newWidth, newHeight, newPixelWidth, newPixelHeight);
  newWidth = max(newWidth, 1);
  newHeight = max(newHeight, 1);

  final oldWidth = _viewWidth;
  final oldHeight = _viewHeight;
  _viewWidth = newWidth;
  _viewHeight = newHeight;

  //we need to resize both buffers so that they are ready when we switch between them
  _altBuffer.resize(oldWidth, oldHeight, newWidth, newHeight);
  _mainBuffer.resize(oldWidth, oldHeight, newWidth, newHeight);

  if (buffer == _altBuffer) {
    buffer.clearScrollback();
  }

  _altBuffer.resetVerticalMargins();
  _mainBuffer.resetVerticalMargins();
}