highlight method

TerminalHighlight highlight({
  1. required CellAnchor p1,
  2. required CellAnchor p2,
  3. required Color color,
})

Creates a new highlight on the terminal from p1 to p2 with the given color. The highlight will be removed when the returned object is disposed.

p2 is exclusive, as a selection's end. A view paints highlights over the text and over the selection (xterm paints the selection last).

Implementation

TerminalHighlight highlight({
  required CellAnchor p1,
  required CellAnchor p2,
  required Color color,
}) {
  final highlight = TerminalHighlight(this, p1: p1, p2: p2, color: color);

  _highlights.add(highlight);
  _addNativeHighlight(highlight);
  notifyListeners();

  highlight.registerCallback(() {
    _highlights.remove(highlight);
    _nativeHighlights.remove(highlight)?.dispose();
    notifyListeners();
  });

  return highlight;
}