selectCharacters method

void selectCharacters(
  1. Offset from, [
  2. Offset? to
])

Selects characters in the terminal that starts from from to to. At least one cell is selected even if from and to are same.

Implementation

void selectCharacters(Offset from, [Offset? to]) {
  final fromPosition = getCellOffset(from);
  if (to == null) {
    _controller.setSelection(
      _terminal.buffer.createAnchorFromOffset(fromPosition),
      _terminal.buffer.createAnchorFromOffset(fromPosition),
    );
  } else {
    var toPosition = getCellOffset(to);
    if (toPosition.x >= fromPosition.x) {
      toPosition = CellOffset(toPosition.x + 1, toPosition.y);
    }
    _controller.setSelection(
      _terminal.buffer.createAnchorFromOffset(fromPosition),
      _terminal.buffer.createAnchorFromOffset(toPosition),
    );
  }
}