resize method

void resize(
  1. int w,
  2. int h
)

Simulates a resize. Real terminals reflow or keep old content in arbitrary ways, so the new grid is filled with junk: the application must repaint every cell.

Implementation

void resize(int w, int h) {
  width = w;
  height = h;
  _grid = _newGrid(w, h);
  // the junk is stored: every row, new and without a length, as long as
  // the screen
  for (final row in _grid) {
    for (final c in row) {
      c
        ..text = '#'
        ..bg = 0x1000000 | 0x123456;
    }
  }
  cx = cx.clamp(0, w - 1);
  cy = cy.clamp(0, h - 1);
  topMargin = 0;
  bottomMargin = h - 1;
  leftMargin = 0;
  rightMargin = w - 1;
  pendingWrap = false;
}