apply method

TerminalViewport apply(
  1. ViewportQuery query, {
  2. double devicePixelRatio = 1.0,
})

Measures query, synchronously resizes the engine when the grid changes, and returns the committed viewport.

Implementation

TerminalViewport apply(
  ViewportQuery query, {
  double devicePixelRatio = 1.0,
}) {
  final next = _resolver.resolve(query, devicePixelRatio: devicePixelRatio);
  final prev = committed;

  if (prev == null || !prev.sameGrid(next) || !_engine.isBound) {
    _engine.resize(columns: next.columns, rows: next.screenLines);
  } else if (!prev.sameCellMetrics(next)) {
    _engine.setCellPixels(
      next.cellWidth.round().clamp(1, 0xFFFF),
      next.cellHeight.round().clamp(1, 0xFFFF),
    );
  }

  committed = next;
  return next;
}