lineSelectionBetweenRows method

  1. @override
GhosttyTerminalSelection? lineSelectionBetweenRows(
  1. int baseRow,
  2. int extentRow
)
override

Returns an inclusive full-row selection across visible rows.

Implementation

@override
GhosttyTerminalSelection? lineSelectionBetweenRows(
  int baseRow,
  int extentRow,
) {
  if (lines.isEmpty) {
    return null;
  }

  final startRow = baseRow.clamp(0, lines.length - 1);
  final endRow = extentRow.clamp(0, lines.length - 1);
  final normalizedStart = math.min(startRow, endRow);
  final normalizedEnd = math.max(startRow, endRow);
  final endLine = lines[normalizedEnd];
  final endCol = math.max(0, endLine.cellCount - 1);
  return GhosttyTerminalSelection(
    base: GhosttyTerminalCellPosition(row: normalizedStart, col: 0),
    extent: GhosttyTerminalCellPosition(row: normalizedEnd, col: endCol),
  );
}