moveNext method

bool moveNext()

Implementation

bool moveNext() {
  final len = _prev.length < _next.length ? _prev.length : _next.length;
  while (_pos < len) {
    final i = _pos;
    _pos++;
    final current = _next[i];
    final previous = _prev[i];

    switch (current.diffOption) {
      case CellDiffOption.skip:
        continue;
      case CellDiffOption.forcedWidth:
        final width = charWidthOf(current.symbol);
        _pos += width - 1;
        if (current != previous) {
          final pos = _posOf(i);
          _current = CellUpdate(pos.x, pos.y, current);
          return true;
        }
        continue;
      case CellDiffOption.none:
      case CellDiffOption.alwaysUpdate:
        final cellWidth = charWidthOf(current.symbol);
        final needsUpdate =
            current.diffOption == CellDiffOption.alwaysUpdate || current != previous;
        if (!needsUpdate) {
          _pos += cellWidth - 1;
          continue;
        }
        final skipExtra = cellWidth > 1 ? cellWidth - 1 : 0;
        _pos += skipExtra;
        final pos = _posOf(i);
        _current = CellUpdate(pos.x, pos.y, current);
        return true;
    }
  }
  return false;
}