cursorPosition static method

String cursorPosition(
  1. int col1,
  2. int row1
)

Returns an ANSI sequence that moves the cursor to 1-based col1/row1.

Implementation

static String cursorPosition(int col1, int row1) {
  // Upstream (`x/ansi`): `CursorPosition(1,1)` compacts to `ESC [ H`.
  if (col1 == 1 && row1 == 1) return cursorHomePosition;
  return '\x1b[$row1;${col1}H';
}